package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.ISendPublicationOrderView;
import com.cloudsigns.factorymanager2.engineering.model.ISendPublicationOrderModel;
import com.cloudsigns.factorymanager2.engineering.model.SendPublicationOrderModel;

/**
 * Created by tony on 2018/5/8.
 */

public class SendPublicationOrderPresenter {
    private ISendPublicationOrderView view;
    private ISendPublicationOrderModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public SendPublicationOrderPresenter(ISendPublicationOrderView view) {
        this.view = view;
        this.model = new SendPublicationOrderModel();
    }

    public void sendPublicationOrder() {


        model.sendPublicationOrder(view.getId(), view.getReceiveAccountId(), new SendPublicationOrderModel.OnSendPublicationOrderListener() {
            @Override
            public void sendPublicationOrderSuccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.sendPublicationOrderSuccess();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void sendPublicationOrderFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.sendPublicationOrderFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
